/*
 */
package edu.wpi.first.wpilibj.util;

import java.awt.Point;
import java.awt.geom.Point2D;

/**
 *
 * @author 8349
 */
public class Point3D{
    
    public double x, y, z;

    public Point3D(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }
    
    public double getX(){
        return x;
    }
    
    public double getY(){
        return y;
    }
    
    public double getZ(){
        return z;
    }
    
    public double distance (Point3D other){
        double diffx = Math.abs (other.x - x);
        double diffy = Math.abs (other.y - y);
        double diffz = Math.abs (other.z - z);
        double distance1 = Math.sqrt(diffx * diffx + (diffy * diffy));
        double distance2 = Math.sqrt (distance1 * distance1 + (diffz * diffz));
        return distance2;
    }
    
    public void setLocation (Point3D p){
        x = p.x;
        y = p.y;
        z = p.z;
    }
    
    public void setLocation (double x, double y, double z){
        this.x = x;
        this.y = y;
        this.z = z;
    }
    
    public void translate(double x, double y, double z){
        this.x += x;
        this.y += y;
        this.z += z;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Point3D other = (Point3D) obj;
        if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x)) {
            return false;
        }
        if (Double.doubleToLongBits(this.y) != Double.doubleToLongBits(other.y)) {
            return false;
        }
        if (Double.doubleToLongBits(this.z) != Double.doubleToLongBits(other.z)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 67 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32));
        hash = 67 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32));
        hash = 67 * hash + (int) (Double.doubleToLongBits(this.z) ^ (Double.doubleToLongBits(this.z) >>> 32));
        return hash;
    }

    @Override
    public String toString() {
        return "Point3D{" + "x = " + x + ", y = " + y + ", z = " + z + '}';
    }
    
    
    
}
